<template>
  excel导入：
  <div class="box">
    <el-upload
      class="avatar-uploader"
      action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
      :show-file-list="false"
      :http-request="handleexcel"
    >
      <el-icon class="avatar-uploader-icon"><Plus /></el-icon>
    </el-upload>
  </div>

  <div id="tablecontinar"></div>
</template>

<script setup>
import { excelInport } from "@/api/excel.js";
function handleexcel(options) {
  const file = options.file;
  const types = file.name.split(".")[1];
  const filetype = ["xlsx", "xlc", "xlm", "xls", "xlt"].some(
    (item) => item === types
  );
  if (!filetype) {
    ElMessage.error("校验不通过，请检查文件类型");
    return;
  }
  const output = document.getElementById("tablecontinar");
  excelInport(file, output);
}
</script>

<style lang="scss" scoped>
.box {
  width: 180px;
  height: 180px;
  border: 1px solid black;
}
.box:hover {
  border: rgb(241, 238, 239) 1px solid;
}
.avatar-uploader .el-upload {
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
}

.avatar-uploader .el-upload:hover {
  border-color: var(--el-color-primary);
}

.el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  text-align: center;
}
:deep(table) {
  width: 100%;
  border-collapse: collapse;
  margin: 0 auto;
  text-align: center;
  td,
  th {
    min-height: 80px;
    border: 1px solid black;
    color: #666;
  }
  thead th {
    background-color: #cce8eb;
    width: 100%;
  }
  tr:nth-child(odd) {
    background: #fff;
  }
  tr:nth-child(even) {
    background: #f5fafa;
  }
}
</style>
